package org.skycastle.megastructure

import com.jme.light.DirectionalLight
import com.jme.math.Vector3f
import com.jme.renderer.ColorRGBA
import com.jme.system.DisplaySystem
import com.jme.scene.state.LightState

/**
 * 
 *
 * @author Hans Haggstrom
 */

class DirectedLight {

  private var lightState : LightState  = null

  def getLightState( display : DisplaySystem ) : LightState = {

    if (lightState == null) {
        /** Set up a basic, default light. */
        val light = new DirectionalLight();
        light.setDiffuse(new ColorRGBA(1.0f, 0.9f, 0.5f, 1.0f));
        light.setAmbient(new ColorRGBA(0.1f, 0.6f, 0.9f, 1.0f));
        light.setDirection(new Vector3f(2,-1,0.5f));
        light.setEnabled(true);

          /** Attach the light to a lightState and the lightState to rootNode. */
        lightState = display.getRenderer().createLightState();
        lightState.setEnabled(true);
        lightState.setTwoSidedLighting(true)
        lightState.attach(light);
    }

    lightState
  }

}